<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/animate.css@3.5.1" rel="stylesheet" type="text/css">
    <title>Document</title>
    <style>
        .list-item {
            display: inline-block;
            margin-right: 10px;
        }

    </style>
</head>

<body>
    <div id="app">
        <button @click='add'>Add</button>
        <button @click='remove'>Remove</button>
        <transition-group name='list' tag='p' enter-active-class='animate__backOutDown' leave-active-class="animated bounceOutRight">
            <span v-for='item in items' class="list-item" :key='item'>{{item}}</span>
        </transition-group>
    </div>

    <script>
        new Vue({
            el: "#app",
            data: {
                show: true,
                items: [1, 2, 3, 4, 5, 6, 7, 8, 9],
                nextNum: 10,
            },
            methods: {
                randomIndex() {
                    return Math.floor(Math.random() * this.items.length);
                },
                add() {
                    this.items.splice(this.randomIndex(), 0, this.nextNum++);
                },
                remove() {
                    this.items.splice(this.randomIndex(), 1)
                }
            },
        })

    </script>
</body>

</html>